package cn.edu.scau.cmi.zenghanxiong.Singleton;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class SingletonController2 {
    private Marshal marshal;
    @FXML
    private TextField input;

    @FXML
    private TextArea output;

    public void buttonAction(ActionEvent event) {
        String name = input.getText();
        if ("".equals(name)) {
            output.appendText("当前输入为空！\n");
            return;
        }
        marshal = Marshal.getInstance(name);
        if (marshal == null) {
            output.appendText("对不起，最多只有十个元帅，" + name + "不能再添加了！\n");
        } else {
            output.appendText(
                    marshal.toString() + "，姓名:" + marshal.getName() + "\n");
        }
    }

}
